﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="PersonalInfo.ascx.cs" Inherits="UserControl_PersonalInfo" %>
<%@ Register src="~/UserControl/MyLogin.ascx" TagPrefix="uc" TagName="login" %>



<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table>

        <tr>
            <td  height="150">

<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
    DataSourceID="SqlDataSource1" 
    style="margin-right: 2px; margin-left = 5px"
    CellPadding="20" 
                    Width="500px" Height="330px" 
                    EditRowStyle-VerticalAlign="Middle" 
                    CellSpacing="10" GridLines="None">
    <RowStyle VerticalAlign="Middle" Font-Size="Small" />
    <FieldHeaderStyle Font-Bold="True" Font-Size="13pt" Width="150px" />
    <EmptyDataTemplate>
        <asp:HyperLink ID="hlErrorMessage" runat="server" NavigateUrl="~/index.aspx" Text="Bạn 
        chưa đăng nhập, click vào đây để đăng nhập."></asp:HyperLink>
    </EmptyDataTemplate>
    <Fields>
        <asp:BoundField DataField="TenLoaiNguoiDung" HeaderText="Loại người dùng" 
            SortExpression="TenLoaiNguoiDung" ReadOnly="True" />
        <asp:TemplateField HeaderText="Tên người dùng" SortExpression="TenNguoiDung">
            <ItemTemplate>
                <asp:Label ID="Label3" runat="server" Text='<%# Bind("TenNguoiDung") %>'></asp:Label>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("TenNguoiDung") %>'></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                    ControlToValidate="TextBox3" ErrorMessage="Tên người dùng không được bỏ trống" 
                    ValidationGroup="Edit">*</asp:RequiredFieldValidator>
            </EditItemTemplate>
            <InsertItemTemplate>
                <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("TenNguoiDung") %>'></asp:TextBox>
            </InsertItemTemplate>
            <ItemStyle Width="300px" VerticalAlign="Middle" />
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Mật khẩu" SortExpression="MatKhau">
            <ItemTemplate>
                <asp:Label ID="Label1" runat="server" Text="******"></asp:Label>
            </ItemTemplate>
            <EditItemTemplate>
               <table  cellspacing="0" cellpadding="0" width="100%"  align="center">
               	<tr>
               		<td> <asp:TextBox ID="txtMatKhau" runat="server" MaxLength="100" 
                    Text='<%# Bind("MatKhau") %>' TextMode="Password"></asp:TextBox>
                </td>
                <td><asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                    ControlToValidate="txtMatKhau" ErrorMessage="Mật khẩu nhiều hơn 6 kí tự" 
                    ValidationExpression="[.\S0-9,a-z,A-Z]{6,}" ValidationGroup="Edit">*</asp:RegularExpressionValidator>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" 
                        ControlToValidate="txtMatKhau" ErrorMessage="Mật khẩu không được bỏ trống" 
                        ValidationGroup="Edit">*</asp:RequiredFieldValidator>
                    </td>
               	</tr>
               	<tr>
               	<td>
                       <asp:TextBox ID="txtXacNhanMatKhau" runat="server"></asp:TextBox>
               	</td>
               	<td>
                       <asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="Xác nhận lại mật khẩu" ControlToValidate="txtMatKhau" ControlToCompare="txtXacNhanMatKhau" ValidationGroup="Edit">*</asp:CompareValidator>
               	</td>
               	</tr>
               </table>
               
            </EditItemTemplate>
            <InsertItemTemplate>
                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("MatKhau") %>'></asp:TextBox>
            </InsertItemTemplate>
            <ItemStyle VerticalAlign="Middle" />
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Email" SortExpression="Email">
            <ItemTemplate>
                <asp:Label ID="Label4" runat="server" Text='<%# Bind("Email") %>'></asp:Label>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Email") %>'></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                    ControlToValidate="TextBox4" ErrorMessage="Email không được bỏ trống" 
                    ValidationGroup="Edit">*</asp:RequiredFieldValidator>
            </EditItemTemplate>
            <InsertItemTemplate>
                <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Email") %>'></asp:TextBox>
            </InsertItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="TenDangNhap" HeaderText="Tên đăng nhập" 
            SortExpression="TenDangNhap" ReadOnly="True" />
        <asp:TemplateField HeaderText="CMND" SortExpression="SoCMND">
            <ItemTemplate>
                <asp:Label ID="Label2" runat="server" Text='<%# Bind("SoCMND") %>'></asp:Label>
            </ItemTemplate>
            <EditItemTemplate >
                <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("SoCMND") %>' 
                    ReadOnly="True"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                    ControlToValidate="TextBox2" ErrorMessage="Không được bỏ trống" 
                    ValidationGroup="Edit" Text="*"></asp:RequiredFieldValidator>
            </EditItemTemplate>
            <InsertItemTemplate>
                <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("SoCMND") %>'></asp:TextBox>
            </InsertItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="DienThoai" HeaderText="Điện thoại" 
            SortExpression="DienThoai" />
        <asp:BoundField DataField="ThoiGianDangKy" HeaderText="Thời điểm đăng ký" 
            ReadOnly="True" SortExpression="ThoiGianDangKy" />
        <asp:BoundField DataField="DiemVIP" HeaderText="Điểm VIP" 
            SortExpression="DiemVIP">
            <ItemStyle Font-Bold="True" ForeColor="Red" />
        </asp:BoundField>
        <asp:TemplateField ShowHeader="False">
            <ItemTemplate>
                <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                    CommandName="Edit" Text="Edit"></asp:LinkButton>
                &nbsp;<asp:HyperLink ID="LinkButton2" runat="server" Text="Tin nhắn" NavigateUrl="~/Message/XemTinNhan.aspx"></asp:HyperLink>
                &nbsp;<asp:HyperLink ID="LinkButton3" runat="server" Text="Nạp tiền" NavigateUrl="~/Account/Payment.aspx"></asp:HyperLink>
                &nbsp;<asp:HyperLink ID="HyperLink1" runat="server" Text="Tin rao vặt đã gửi" NavigateUrl="~/Account/DanhSachTinRaoVat.aspx"></asp:HyperLink>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" 
                    Text="Update" ValidationGroup="Edit" CommandName="Update"></asp:LinkButton>
                &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                    CommandName="Cancel" Text="Cancel"></asp:LinkButton>
            </EditItemTemplate>
        </asp:TemplateField>
    </Fields>
    <HeaderStyle Font-Bold="True" Font-Size="13pt" />
    <EditRowStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:DetailsView>

               
</td>
<tr>
<td> 
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:RAOVATConnectionString %>" 
        SelectCommand="SELECT LOAI_NGUOI_DUNG.TenLoaiNguoiDung, NGUOI_DUNG.TenNguoiDung, NGUOI_DUNG.TenDangNhap, NGUOI_DUNG.MatKhau, NGUOI_DUNG.Email, NGUOI_DUNG.DienThoai, NGUOI_DUNG.SoCMND, NGUOI_DUNG.DiaChi, NGUOI_DUNG.ThoiGianDangKy, NGUOI_DUNG.DiemVIP FROM NGUOI_DUNG INNER JOIN LOAI_NGUOI_DUNG ON NGUOI_DUNG.MaLoaiNguoiDung = LOAI_NGUOI_DUNG.MaLoaiNguoiDung WHERE (NGUOI_DUNG.TenDangNhap = @TenDangNhap)" 
        
        UpdateCommand="UPDATE NGUOI_DUNG SET TenNguoiDung = @TenNguoiDung, MatKhau = @MatKhau, Email = @Email, DienThoai = @DienThoai, SoCMND = @SoCMND, DiaChi = @DiaChia WHERE (TenDangNhap = @TenDangNhap)">
        <SelectParameters>
            <asp:SessionParameter DefaultValue="0" Name="TenDangNhap" 
                SessionField="TenDangNhap" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="TenNguoiDung" />
            <asp:Parameter Name="MatKhau" />
            <asp:Parameter Name="Email" />
            <asp:Parameter Name="DienThoai" />
            <asp:Parameter Name="SoCMND" />
            <asp:Parameter Name="DiaChia" />
            <asp:QueryStringParameter DefaultValue="0" Name="TenDangNhap" 
                QueryStringField="TenDangNhap" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <asp:ValidationSummary ID="ValidationSummary1" runat="server"  ValidationGroup="Edit"/></td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>